/*
* 测试initializer_list在类中的使用
*/
#include <iostream>
#include <initializer_list>
#include <string>

class Person{
    public:
    Person(std::string name, int age) :name_(name), age_(age){
        std::cout << "construct using normal " << std::endl;
    }

    Person(std::initializer_list<std::string> value)
    // :name_(*value.begin()),age_(std::stoi(*(value.begin()+1)))
    :name_(*value.begin()),age_(std::stoi(*(value.end() - 1)))//same with above
    {
        std::cout << "construct using initializer_list " << std::endl;
    }

    void printInfo() const{
        std::cout << "Name: "<< name_ << " age: "<< age_ << std::endl;
    }

    private:
    int age_;
    std::string name_;
};

int main(){
    Person tttt("tttt",25);
    tttt.printInfo();
    Person yyyy{"tyj","25"};
    yyyy.printInfo();
}